﻿package net.wangit.jdbc.type;

import net.wangit.Row;
import net.wangit.jdbc.database.Database;
import net.wangit.util.StringUtil;

public abstract class ScaleType extends PrecisionType {
	private static final String SCALE_PLACEHOLDER = "$s";
	protected int scale;

	public ScaleType(Row row) {
		super(row);
		scale = row.getInt("s", 0);
	}

	public String getSqlTypeName(Database database) {
		String sqlTypeName = super.getSqlTypeName(database);
		return dealwithScale(sqlTypeName);
	}

	private String dealwithScale(String sqlTypeName) {
		return StringUtil.replace(sqlTypeName, ScaleType.SCALE_PLACEHOLDER,
				Integer.toString(scale));
	}
}
